Skip to content

fix: never record a review the inventory cannot read back - #343

Open
vinceblock99 wants to merge 1 commit into
devfrom
fix/review-record-readable
Open

vinceblock99 wants to merge 1 commit into
devfrom
fix/review-record-readable

Conversation

@vinceblock99

Copy link
Copy Markdown
Contributor

Problem

Two limits were enforced only when stored reviews are read. A review could be recorded successfully and then make the whole inventory unreadable. Entries under publication-reviews/ cannot be deleted, so there was no way back.

  • Size. The 1 MiB bound is defined on the compact signed document, but the artifact was stored pretty-printed, about a third larger. A review whose compact form was over roughly 770 KiB passed prepare, was recorded, and was then refused on every read.
  • Count. The inventory refuses to list more than 4096 artifacts, but recording the 4097th succeeded.

Fix

record_publication_review now:

  • stores the compact signed document;
  • admits the bytes exactly as the reader will before writing them, and refuses a review that would not read back;
  • refuses a new artifact when the inventory already holds 4096.

Both refusals happen before anything is created on disk or in the vault.

Reviews already stored pretty-printed stay as they are, and recording one of them again remains a no-op. The content address does not depend on the stored encoding, so no address changes.

Tests

  • New publication_review::tests::storage:
    • A recorded review is stored no larger than its signed document. On dev a 9,112 byte document was stored as 13,050 bytes.
    • A full inventory refuses another review and stays listable. On dev the 4097th record succeeded.
    • A review of exactly the bound is storable and reads back; one byte more is refused before it is written.
    • A review stored in the earlier pretty encoding can be recorded again, its stored bytes are untouched, and it still satisfies the gate.
  • cargo test -p atomic-repository --features review-shacl --lib publication_review: 46 passed, 0 failed.

Two limits were enforced only when stored reviews are read, so a review
could be recorded successfully and then make the whole inventory
unreadable. Entries under publication-reviews/ cannot be deleted, so
there was no way back.

- Size. The 1 MiB bound is defined on the compact signed document, but
  the artifact was stored pretty-printed, about a third larger. A review
  whose compact form was over roughly 770 KiB passed prepare, was
  recorded, and was then refused on every read.
- Count. The inventory refuses to list more than 4096 artifacts, but
  recording the 4097th succeeded.

Recording now stores the compact document, admits the bytes exactly as
the reader will before writing them, and refuses a new artifact when
the inventory is full. Both refusals happen before anything is created
on disk or in the vault. Reviews already stored pretty-printed stay as
they are, and recording one of them again remains a no-op.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant